wayland: Use a magic mime type for local DND
authorBenjamin Otte <otte@redhat.com>
Sat, 15 Feb 2020 20:04:57 +0000 (21:04 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 15 Feb 2020 21:33:57 +0000 (22:33 +0100)
Otherwise the compositor gets all confused when it's trying to make
drag happen but we know it's not going to happen.

After all, we exchange data behind its back, we just need to keep it
informed.

gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkdrag-wayland.c
gdk/wayland/gdkdrop-wayland.c
gdk/wayland/gdkprivate-wayland.h

index 4bc5a55b046faae86adc5b41ed5d872382176ea0..8ef0a3ae03884e75bcef4d7ff267487448c35780 100644 (file)
@@ -1127,6 +1127,10 @@ data_offer_offer (void                 *data,
       return;
     }
 
+  /* skip magic mime types */
+  if (g_str_equal (type, GDK_WAYLAND_LOCAL_DND_MIME_TYPE))
+    return;
+
   gdk_content_formats_builder_add_mime_type (seat->pending_builder, type);
 }
 
index fd4dc9ec988a64d650e259a9b815c81b5d3fb380..f7c2925c606accdb74b54798f0dc8d065c3281b5 100644 (file)
@@ -358,6 +358,7 @@ gdk_wayland_drag_create_data_source (GdkDrag *drag)
             g_message ("create data source, mime types=%s", s);
             g_free (s);});
 
+  wl_data_source_offer (drag_wayland->data_source, GDK_WAYLAND_LOCAL_DND_MIME_TYPE);
   for (i = 0; i < n_mimetypes; i++)
     wl_data_source_offer (drag_wayland->data_source, mimetypes[i]);
 
index b7f74e87431e19b5981713e142febfa96c93b98d..a638b6314f6e52798e5813af17b99b4ed363c5c0 100644 (file)
@@ -97,6 +97,13 @@ gdk_wayland_drop_drop_set_status (GdkWaylandDrop *drop_wayland,
       const char *const *mimetypes;
       gsize i, n_mimetypes;
       
+      /* This is a local drag, treat it like that */
+      if (gdk_drop_get_drag (GDK_DROP (drop_wayland)))
+        {
+          wl_data_offer_accept (drop_wayland->offer, drop_wayland->serial, GDK_WAYLAND_LOCAL_DND_MIME_TYPE);
+          return;
+        }
+
       mimetypes = gdk_content_formats_get_mime_types (gdk_drop_get_formats (GDK_DROP (drop_wayland)), &n_mimetypes);
       for (i = 0; i < n_mimetypes; i++)
         {
index 8130a323a1b206c23644d65a932696660a46b48d..233e972cc4f6fdf3f2b218d77424b3ce4fbc66f1 100644 (file)
 #define WL_SURFACE_HAS_BUFFER_SCALE 3
 #define WL_POINTER_HAS_FRAME 5
 
+/* the magic mime type we use for local DND operations.
+ * We offer it to every dnd operation, but will strip it out on the drop
+ * site unless we can prove it's a local DND - then we will use only
+ * this type
+ */
+#define GDK_WAYLAND_LOCAL_DND_MIME_TYPE "application/x-gtk-local-dnd"
+
 GdkKeymap *_gdk_wayland_keymap_new (GdkDisplay *display);
 void       _gdk_wayland_keymap_update_from_fd (GdkKeymap *keymap,
                                                uint32_t   format,